﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace sunsetmp.DialogWindow
{
    /// <summary>
    /// Interaction logic for CaptchaWindow.xaml
    /// </summary>
    public partial class CaptchaWindow : Window
    {
        ThrearWorkClass threadWorker;
        object[] par;
        string id;

        public CaptchaWindow(ThrearWorkClass tw, object[] param)
        {
            InitializeComponent();
            threadWorker = tw;
            BitmapImage myBitmapImage = new BitmapImage();
            myBitmapImage.BeginInit();
            myBitmapImage.UriSource = new Uri(param[4].ToString());
            myBitmapImage.DecodePixelWidth = 200;
            myBitmapImage.EndInit();
            Captcha.Source = myBitmapImage;
            id = param[5].ToString();
            par = param;
            this.Show();
        }

        private void ConnectButton_Click_1(object sender, RoutedEventArgs e)
        {
            if (CapchaTextBox.Text.Length != 0)
                threadWorker.SendCaptcha(CapchaTextBox.Text, id, par);
            this.Close();
        }

        private void OfflineButton_Click_1(object sender, RoutedEventArgs e)
        {
            threadWorker.CancelWebAddition();
            this.Close();
        }

        private void Border_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        private void CloseW_Click_1(object sender, RoutedEventArgs e)
        {
            threadWorker.CancelWebAddition();
            this.Close();
        }
    }
}
